package com.gdcp.service.impl;

import com.gdcp.beans.Shipping;
import com.gdcp.mapper.ShippingMapper;
import com.gdcp.service.ShippingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 杨华京
 * @version 1.0
 * @description
 * @since 1.8
 */
@Service
public class ShippingServiceImpl implements ShippingService {

    @Autowired
    ShippingMapper shippingMapper;

    @Override
    public int insert(Shipping shipping) {
        return shippingMapper.insert(shipping);
    }

    @Override
    public List<Shipping> queryListById(Integer id) {
        List<Shipping> shippings=shippingMapper.queryListById(id);
        return shippings;
    }

    @Override
    public Shipping queryById(Integer address_id) {
        Shipping shipping=shippingMapper.queryById(address_id);
        return shipping;
    }

    @Override
    public int updateAddress(Shipping shipping) {
        try{
            shippingMapper.updateAddress(shipping);
        }catch (Exception e){
            e.printStackTrace();
            return 0;
        }
        return 1;
    }

    @Override
    public int deleteById(Integer id) {
        try{
            shippingMapper.deleteById(id);
        }catch (Exception e){
            e.printStackTrace();
            return 0;
        }
        return 1;
    }

    @Override
    public Shipping getInformation(Integer valueOf) {
        return shippingMapper.getInformation(valueOf);
    }
}
